package com.library.service.impl;

import com.library.service.LendListService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.library.dao.BookInfoMapper;
import com.library.dao.LendListMapper;
import com.library.po.BookInfo;
import com.library.po.LendList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


@Service("lendListService")
public class LendListServiceImpl implements LendListService {

    @Autowired
    private LendListMapper lendListMapper;
    @Autowired
    private BookInfoMapper bookInfoMapper;


    @Override
    public PageInfo<LendList> queryLendListAll(LendList lendList, int page, int limit) {
        PageHelper.startPage(page,limit);
        List<LendList> list=lendListMapper.queryLendListAll(lendList);

        PageInfo pageInfo=new PageInfo(list);
        return pageInfo;
    }


    @Override
    public List<LendList> queryLookBookList(Integer rid, Integer bid) {
        return lendListMapper.queryLookBookList(rid, bid);
    }

    /**
     * 查询当前用户的借阅记录
     */
    @Override
    public PageInfo<LendList> queryLendListAll2(LendList lendList, int page, int limit) {
        PageHelper.startPage(page,limit);
        List<LendList> list=lendListMapper.queryLendListAll2(lendList);

        PageInfo pageInfo=new PageInfo(list);
        return pageInfo;
    }

    @Override
    public LendList queryAllLendList(String id) {
        return lendListMapper.selectByPrimaryKey(Integer.parseInt(id));
    }

    @Override
    public int queryLendListCount(int bookId) {
        return lendListMapper.queryLendListCount(bookId);
    }

    @Override
    public int queryLendListCount2(int bookId) {
        return lendListMapper.queryLendListCount2(bookId);
    }
}
